<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>练习题</title>
</head>

<body>
  <script>
    function isWin() {
      count++;
      var arr = []
      var result = false
      for (let i = 0; i < 3; i++) {
        var num = Math.floor(Math.random() * 9) + 1;
        arr.push(num);
      }
      for (let i = 0; i < arr.length; i++) {
        if (arr[i] == 8) {
          result = true;
          winCount++
        }
      }
      return {
        arr: arr,
        result: result
      };
    }
    var count = 0;
    var winCount = 0;
    var res = isWin();
    var isGo = confirm(`本次结果：${res.arr} \n${res.result ? '赢' : '输'}\n 胜率：${winCount / count * 100 + '%'}\n 还玩不? \n `)
    while (isGo) {
      res = isWin()
      isGo = confirm(`本次结果：${res.arr} \n${res.result ? '赢' : '输'}\n 胜率：${winCount / count * 100 + '%'}\n 还玩不? \n `)
    }
  </script>
</body>

</html>